home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / standards.info-1.z / standards.info-1
Encoding:
GNU Info File  |  1998-05-21  |  48.6 KB  |  1,972 lines

  1. This is Info file ../info/standards.info, produced by Makeinfo version
  2. 1.68 from the input file standards.texi.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Standards: (standards).        GNU coding standards.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    GNU Coding Standards Copyright (C) 1992, 1993, 1994, 1995, 1996 Free
  9. Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided that
  17. the entire resulting derived work is distributed under the terms of a
  18. permission notice identical to this one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that this permission notice may be stated in a
  23. translation approved by the Free Software Foundation.
  24.  
  25. 
  26. File: standards.info,  Node: Top,  Next: Preface,  Prev: (dir),  Up: (dir)
  27.  
  28. Version
  29. *******
  30.  
  31.    Last updated 17 May 1996.
  32.  
  33. * Menu:
  34.  
  35. * Preface::            About the GNU Coding Standards
  36. * Intellectual Property::       Keeping Free Software Free
  37. * Design Advice::               General Program Design
  38. * Program Behavior::            Program Behavior for All Programs
  39. * Writing C::                   Making The Best Use of C
  40. * Documentation::        Documenting Programs
  41. * Managing Releases::           The Release Process
  42.  
  43. 
  44. File: standards.info,  Node: Preface,  Next: Intellectual Property,  Prev: Top,  Up: Top
  45.  
  46. About the GNU Coding Standards
  47. ******************************
  48.  
  49.    The GNU Coding Standards were written by Richard Stallman and other
  50. GNU Project volunteers.  Their purpose is to make the GNU system clean,
  51. consistent, and easy to install.  This document can also be read as a
  52. guide to writing portable, robust and reliable programs.  It focuses on
  53. programs written in C, but many of the rules and principles are useful
  54. even if you write in another programming language.  The rules often
  55. state reasons for writing in a certain way.
  56.  
  57.    Corrections or suggestions regarding this document should be sent to
  58. `gnu@prep.ai.mit.edu'.  If you make a suggestion, please include a
  59. suggested new wording for it; our time is limited.  We prefer a context
  60. diff to the `standards.texi' or `make-stds.texi' files, but if you
  61. don't have those files, please mail your suggestion anyway.
  62.  
  63.    This release of the GNU Coding Standards was last updated 17 May
  64. 1996.
  65.  
  66. 
  67. File: standards.info,  Node: Intellectual Property,  Next: Design Advice,  Prev: Preface,  Up: Top
  68.  
  69. Keeping Free Software Free
  70. **************************
  71.  
  72.    This node discusses how you can make sure that GNU software remains
  73. unencumbered.
  74.  
  75. * Menu:
  76.  
  77. * Reading Non-Free Code::    Referring to Proprietary Programs
  78. * Contributions::        Accepting Contributions
  79.  
  80. 
  81. File: standards.info,  Node: Reading Non-Free Code,  Next: Contributions,  Up: Intellectual Property
  82.  
  83. Referring to Proprietary Programs
  84. =================================
  85.  
  86.    Don't in any circumstances refer to Unix source code for or during
  87. your work on GNU!  (Or to any other proprietary programs.)
  88.  
  89.    If you have a vague recollection of the internals of a Unix program,
  90. this does not absolutely mean you can't write an imitation of it, but
  91. do try to organize the imitation internally along different lines,
  92. because this is likely to make the details of the Unix version
  93. irrelevant and dissimilar to your results.
  94.  
  95.    For example, Unix utilities were generally optimized to minimize
  96. memory use; if you go for speed instead, your program will be very
  97. different.  You could keep the entire input file in core and scan it
  98. there instead of using stdio.  Use a smarter algorithm discovered more
  99. recently than the Unix program.  Eliminate use of temporary files.  Do
  100. it in one pass instead of two (we did this in the assembler).
  101.  
  102.    Or, on the contrary, emphasize simplicity instead of speed.  For some
  103. applications, the speed of today's computers makes simpler algorithms
  104. adequate.
  105.  
  106.    Or go for generality.  For example, Unix programs often have static
  107. tables or fixed-size strings, which make for arbitrary limits; use
  108. dynamic allocation instead.  Make sure your program handles NULs and
  109. other funny characters in the input files.  Add a programming language
  110. for extensibility and write part of the program in that language.
  111.  
  112.    Or turn some parts of the program into independently usable
  113. libraries.  Or use a simple garbage collector instead of tracking
  114. precisely when to free memory, or use a new GNU facility such as
  115. obstacks.
  116.  
  117. 
  118. File: standards.info,  Node: Contributions,  Prev: Reading Non-Free Code,  Up: Intellectual Property
  119.  
  120. Accepting Contributions
  121. =======================
  122.  
  123.    If someone else sends you a piece of code to add to the program you
  124. are working on, we need legal papers to use it--the same sort of legal
  125. papers we will need to get from you.  *Each* significant contributor to
  126. a program must sign some sort of legal papers in order for us to have
  127. clear title to the program.  The main author alone is not enough.
  128.  
  129.    So, before adding in any contributions from other people, tell us so
  130. we can arrange to get the papers.  Then wait until we tell you that we
  131. have received the signed papers, before you actually use the
  132. contribution.
  133.  
  134.    This applies both before you release the program and afterward.  If
  135. you receive diffs to fix a bug, and they make significant changes, we
  136. need legal papers for it.
  137.  
  138.    You don't need papers for changes of a few lines here or there, since
  139. they are not significant for copyright purposes.  Also, you don't need
  140. papers if all you get from the suggestion is some ideas, not actual code
  141. which you use.  For example, if you write a different solution to the
  142. problem, you don't need to get papers.
  143.  
  144.    We know this is frustrating; it's frustrating for us as well.  But if
  145. you don't wait, you are going out on a limb--for example, what if the
  146. contributor's employer won't sign a disclaimer?  You might have to take
  147. that code out again!
  148.  
  149.    The very worst thing is if you forget to tell us about the other
  150. contributor.  We could be very embarrassed in court some day as a
  151. result.
  152.  
  153. 
  154. File: standards.info,  Node: Design Advice,  Next: Program Behavior,  Prev: Intellectual Property,  Up: Top
  155.  
  156. General Program Design
  157. **********************
  158.  
  159.    This node discusses some of the issues you should take into account
  160. when designing your program.
  161.  
  162. * Menu:
  163.  
  164. * Compatibility::        Compatibility with other implementations
  165. * Using Extensions::        Using non-standard features
  166. * ANSI C::                      Using ANSI C features
  167. * Source Language::        Using languages other than C
  168.  
  169. 
  170. File: standards.info,  Node: Compatibility,  Next: Using Extensions,  Up: Design Advice
  171.  
  172. Compatibility with Other Implementations
  173. ========================================
  174.  
  175.    With occasional exceptions, utility programs and libraries for GNU
  176. should be upward compatible with those in Berkeley Unix, and upward
  177. compatible with ANSI C if ANSI C specifies their behavior, and upward
  178. compatible with POSIX if POSIX specifies their behavior.
  179.  
  180.    When these standards conflict, it is useful to offer compatibility
  181. modes for each of them.
  182.  
  183.    ANSI C and POSIX prohibit many kinds of extensions.  Feel free to
  184. make the extensions anyway, and include a `--ansi', `--posix', or
  185. `--compatible' option to turn them off.  However, if the extension has
  186. a significant chance of breaking any real programs or scripts, then it
  187. is not really upward compatible.  Try to redesign its interface.
  188.  
  189.    Many GNU programs suppress extensions that conflict with POSIX if the
  190. environment variable `POSIXLY_CORRECT' is defined (even if it is
  191. defined with a null value).  Please make your program recognize this
  192. variable if appropriate.
  193.  
  194.    When a feature is used only by users (not by programs or command
  195. files), and it is done poorly in Unix, feel free to replace it
  196. completely with something totally different and better.  (For example,
  197. `vi' is replaced with Emacs.)  But it is nice to offer a compatible
  198. feature as well.  (There is a free `vi' clone, so we offer it.)
  199.  
  200.    Additional useful features not in Berkeley Unix are welcome.
  201. Additional programs with no counterpart in Unix may be useful, but our
  202. first priority is usually to duplicate what Unix already has.
  203.  
  204. 
  205. File: standards.info,  Node: Using Extensions,  Next: ANSI C,  Prev: Compatibility,  Up: Design Advice
  206.  
  207. Using Non-standard Features
  208. ===========================
  209.  
  210.    Many GNU facilities that already exist support a number of convenient
  211. extensions over the comparable Unix facilities.  Whether to use these
  212. extensions in implementing your program is a difficult question.
  213.  
  214.    On the one hand, using the extensions can make a cleaner program.
  215. On the other hand, people will not be able to build the program unless
  216. the other GNU tools are available.  This might cause the program to
  217. work on fewer kinds of machines.
  218.  
  219.    With some extensions, it might be easy to provide both alternatives.
  220. For example, you can define functions with a "keyword" `INLINE' and
  221. define that as a macro to expand into either `inline' or nothing,
  222. depending on the compiler.
  223.  
  224.    In general, perhaps it is best not to use the extensions if you can
  225. straightforwardly do without them, but to use the extensions if they
  226. are a big improvement.
  227.  
  228.    An exception to this rule are the large, established programs (such
  229. as Emacs) which run on a great variety of systems.  Such programs would
  230. be broken by use of GNU extensions.
  231.  
  232.    Another exception is for programs that are used as part of
  233. compilation: anything that must be compiled with other compilers in
  234. order to bootstrap the GNU compilation facilities.  If these require
  235. the GNU compiler, then no one can compile them without having them
  236. installed already.  That would be no good.
  237.  
  238. 
  239. File: standards.info,  Node: ANSI C,  Next: Source Language,  Prev: Using Extensions,  Up: Design Advice
  240.  
  241. ANSI C and pre-ANSI C
  242. =====================
  243.  
  244.    Do not ever use the "trigraph" feature of ANSI C.
  245.  
  246.    ANSI C is widespread enough now that it is ok to write new programs
  247. that use ANSI C features (and therefore will not work in non-ANSI
  248. compilers).  And if a program is already written in ANSI C, there's no
  249. need to convert it to support non-ANSI compilers.
  250.  
  251.    However, it is easy to support non-ANSI compilers in most programs,
  252. so you might still consider doing so when you write a program.  Instead
  253. of writing function definitions in ANSI prototype form,
  254.  
  255.      int
  256.      foo (int x, int y)
  257.      ...
  258.  
  259. write the definition in pre-ANSI style like this,
  260.  
  261.      int
  262.      foo (x, y)
  263.           int x, y;
  264.      ...
  265.  
  266. and use a separate declaration to specify the argument prototype:
  267.  
  268.      int foo (int, int);
  269.  
  270.    You need such a declaration anyway, in a header file, to get the
  271. benefit of ANSI C prototypes in all the files where the function is
  272. called.  And once you have it, you lose nothing by writing the function
  273. definition in the pre-ANSI style.
  274.  
  275.    If you don't know non-ANSI C, there's no need to learn it; just
  276. write in ANSI C.
  277.  
  278. 
  279. File: standards.info,  Node: Source Language,  Prev: ANSI C,  Up: Design Advice
  280.  
  281. Using Languages Other Than C
  282. ============================
  283.  
  284.    Using a language other than C is like using a non-standard feature:
  285. it will cause trouble for users.  Even if GCC supports the other
  286. language, users may find it inconvenient to have to install the
  287. compiler for that other language in order to build your program.  So
  288. please write in C.
  289.  
  290.    There are three exceptions for this rule:
  291.  
  292.    * It is okay to use a special language if the same program contains
  293.      an interpreter for that language.
  294.  
  295.      For example, if your program links with GUILE, it is ok to write
  296.      part of the program in Scheme or another language supported by
  297.      GUILE.
  298.  
  299.    * It is okay to use another language in a tool specifically intended
  300.      for use with that language.
  301.  
  302.      This is okay because the only people who want to build the tool
  303.      will be those who have installed the other language anyway.
  304.  
  305.    * If an application is not of extremely widespread interest, then
  306.      perhaps it's not important if the application is inconvenient to
  307.      install.
  308.  
  309. 
  310. File: standards.info,  Node: Program Behavior,  Next: Writing C,  Prev: Design Advice,  Up: Top
  311.  
  312. Program Behavior for All Programs
  313. *********************************
  314.  
  315.    This node describes how to write robust software. It also describes
  316. general standards for error messages, the command line interface, and
  317. how libraries should behave.
  318.  
  319. * Menu:
  320.  
  321. * Semantics::            Writing robust programs
  322. * Libraries::            Library behavior
  323. * Errors::            Formatting error messages
  324. * User Interfaces::        Standards for command line interfaces
  325. * Memory Usage::                When and how to care about memory needs
  326.  
  327. 
  328. File: standards.info,  Node: Semantics,  Next: Libraries,  Up: Program Behavior
  329.  
  330. Writing Robust Programs
  331. =======================
  332.  
  333.    Avoid arbitrary limits on the length or number of *any* data
  334. structure, including file names, lines, files, and symbols, by
  335. allocating all data structures dynamically.  In most Unix utilities,
  336. "long lines are silently truncated".  This is not acceptable in a GNU
  337. utility.
  338.  
  339.    Utilities reading files should not drop NUL characters, or any other
  340. nonprinting characters *including those with codes above 0177*.  The
  341. only sensible exceptions would be utilities specifically intended for
  342. interface to certain types of printers that can't handle those
  343. characters.
  344.  
  345.    Check every system call for an error return, unless you know you
  346. wish to ignore errors.  Include the system error text (from `perror' or
  347. equivalent) in *every* error message resulting from a failing system
  348. call, as well as the name of the file if any and the name of the
  349. utility.  Just "cannot open foo.c" or "stat failed" is not sufficient.
  350.  
  351.    Check every call to `malloc' or `realloc' to see if it returned
  352. zero.  Check `realloc' even if you are making the block smaller; in a
  353. system that rounds block sizes to a power of 2, `realloc' may get a
  354. different block if you ask for less space.
  355.  
  356.    In Unix, `realloc' can destroy the storage block if it returns zero.
  357. GNU `realloc' does not have this bug: if it fails, the original block
  358. is unchanged.  Feel free to assume the bug is fixed.  If you wish to
  359. run your program on Unix, and wish to avoid lossage in this case, you
  360. can use the GNU `malloc'.
  361.  
  362.    You must expect `free' to alter the contents of the block that was
  363. freed.  Anything you want to fetch from the block, you must fetch before
  364. calling `free'.
  365.  
  366.    If `malloc' fails in a noninteractive program, make that a fatal
  367. error.  In an interactive program (one that reads commands from the
  368. user), it is better to abort the command and return to the command
  369. reader loop.  This allows the user to kill other processes to free up
  370. virtual memory, and then try the command again.
  371.  
  372.    Use `getopt_long' to decode arguments, unless the argument syntax
  373. makes this unreasonable.
  374.  
  375.    When static storage is to be written in during program execution, use
  376. explicit C code to initialize it.  Reserve C initialized declarations
  377. for data that will not be changed.
  378.  
  379.    Try to avoid low-level interfaces to obscure Unix data structures
  380. (such as file directories, utmp, or the layout of kernel memory), since
  381. these are less likely to work compatibly.  If you need to find all the
  382. files in a directory, use `readdir' or some other high-level interface.
  383. These will be supported compatibly by GNU.
  384.  
  385.    By default, the GNU system will provide the signal handling
  386. functions of BSD and of POSIX.  So GNU software should be written to use
  387. these.
  388.  
  389.    In error checks that detect "impossible" conditions, just abort.
  390. There is usually no point in printing any message.  These checks
  391. indicate the existence of bugs.  Whoever wants to fix the bugs will have
  392. to read the source code and run a debugger.  So explain the problem with
  393. comments in the source.  The relevant data will be in variables, which
  394. are easy to examine with the debugger, so there is no point moving them
  395. elsewhere.
  396.  
  397.    Do not use a count of errors as the exit status for a program.
  398. *That does not work*, because exit status values are limited to 8 bits
  399. (0 through 255).  A single run of the program might have 256 errors; if
  400. you try to return 256 as the exit status, the parent process will see 0
  401. as the status, and it will appear that the program succeeded.
  402.  
  403.    If you make temporary files, check the `TMPDIR' environment
  404. variable; if that variable is defined, use the specified directory
  405. instead of `/tmp'.
  406.  
  407. 
  408. File: standards.info,  Node: Libraries,  Next: Errors,  Prev: Semantics,  Up: Program Behavior
  409.  
  410. Library Behavior
  411. ================
  412.  
  413.    Try to make library functions reentrant.  If they need to do dynamic
  414. storage allocation, at least try to avoid any nonreentrancy aside from
  415. that of `malloc' itself.
  416.  
  417.    Here are certain name conventions for libraries, to avoid name
  418. conflicts.
  419.  
  420.    Choose a name prefix for the library, more than two characters long.
  421. All external function and variable names should start with this prefix.
  422. In addition, there should only be one of these in any given library
  423. member.  This usually means putting each one in a separate source file.
  424.  
  425.    An exception can be made when two external symbols are always used
  426. together, so that no reasonable program could use one without the
  427. other; then they can both go in the same file.
  428.  
  429.    External symbols that are not documented entry points for the user
  430. should have names beginning with `_'.  They should also contain the
  431. chosen name prefix for the library, to prevent collisions with other
  432. libraries.  These can go in the same files with user entry points if
  433. you like.
  434.  
  435.    Static functions and variables can be used as you like and need not
  436. fit any naming convention.
  437.  
  438. 
  439. File: standards.info,  Node: Errors,  Next: User Interfaces,  Prev: Libraries,  Up: Program Behavior
  440.  
  441. Formatting Error Messages
  442. =========================
  443.  
  444.    Error messages from compilers should look like this:
  445.  
  446.      SOURCE-FILE-NAME:LINENO: MESSAGE
  447.  
  448.    Error messages from other noninteractive programs should look like
  449. this:
  450.  
  451.      PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
  452.  
  453. when there is an appropriate source file, or like this:
  454.  
  455.      PROGRAM: MESSAGE
  456.  
  457. when there is no relevant source file.
  458.  
  459.    In an interactive program (one that is reading commands from a
  460. terminal), it is better not to include the program name in an error
  461. message.  The place to indicate which program is running is in the
  462. prompt or with the screen layout.  (When the same program runs with
  463. input from a source other than a terminal, it is not interactive and
  464. would do best to print error messages using the noninteractive style.)
  465.  
  466.    The string MESSAGE should not begin with a capital letter when it
  467. follows a program name and/or file name.  Also, it should not end with
  468. a period.
  469.  
  470.    Error messages from interactive programs, and other messages such as
  471. usage messages, should start with a capital letter.  But they should not
  472. end with a period.
  473.  
  474. 
  475. File: standards.info,  Node: User Interfaces,  Next: Memory Usage,  Prev: Errors,  Up: Program Behavior
  476.  
  477. Standards for Command Line Interfaces
  478. =====================================
  479.  
  480.    Please don't make the behavior of a utility depend on the name used
  481. to invoke it.  It is useful sometimes to make a link to a utility with
  482. a different name, and that should not change what it does.
  483.  
  484.    Instead, use a run time option or a compilation switch or both to
  485. select among the alternate behaviors.
  486.  
  487.    Likewise, please don't make the behavior of the program depend on the
  488. type of output device it is used with.  Device independence is an
  489. important principle of the system's design; do not compromise it merely
  490. to save someone from typing an option now and then.
  491.  
  492.    If you think one behavior is most useful when the output is to a
  493. terminal, and another is most useful when the output is a file or a
  494. pipe, then it is usually best to make the default behavior the one that
  495. is useful with output to a terminal, and have an option for the other
  496. behavior.
  497.  
  498.    Compatibility requires certain programs to depend on the type of
  499. output device.  It would be disastrous if `ls' or `sh' did not do so in
  500. the way all users expect.  In some of these cases, we supplement the
  501. program with a preferred alternate version that does not depend on the
  502. output device type.  For example, we provide a `dir' program much like
  503. `ls' except that its default output format is always multi-column
  504. format.
  505.  
  506.    It is a good idea to follow the POSIX guidelines for the
  507. command-line options of a program.  The easiest way to do this is to use
  508. `getopt' to parse them.  Note that the GNU version of `getopt' will
  509. normally permit options anywhere among the arguments unless the special
  510. argument `--' is used.  This is not what POSIX specifies; it is a GNU
  511. extension.
  512.  
  513.    Please define long-named options that are equivalent to the
  514. single-letter Unix-style options.  We hope to make GNU more user
  515. friendly this way.  This is easy to do with the GNU function
  516. `getopt_long'.
  517.  
  518.    One of the advantages of long-named options is that they can be
  519. consistent from program to program.  For example, users should be able
  520. to expect the "verbose" option of any GNU program which has one, to be
  521. spelled precisely `--verbose'.  To achieve this uniformity, look at the
  522. table of common long-option names when you choose the option names for
  523. your program.  The table appears below.
  524.  
  525.    If you use names not already in the table, please send
  526. `gnu@prep.ai.mit.edu' a list of them, with their meanings, so we can
  527. update the table.
  528.  
  529.    It is usually a good idea for file names given as ordinary arguments
  530. to be input files only; any output files would be specified using
  531. options (preferably `-o').  Even if you allow an output file name as an
  532. ordinary argument for compatibility, try to provide a suitable option
  533. as well.  This will lead to more consistency among GNU utilities, so
  534. that there are fewer idiosyncracies for users to remember.
  535.  
  536.    Programs should support an option `--version' which prints the
  537. program's version number on standard output and exits successfully, and
  538. an option `--help' which prints option usage information on standard
  539. output and exits successfully.  These options should inhibit the normal
  540. function of the command; they should do nothing except print the
  541. requested information.
  542.  
  543.    Here is the table of long options used by GNU programs.
  544.  
  545. `after-date'
  546.      `-N' in `tar'.
  547.  
  548. `all'
  549.      `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
  550.  
  551. `all-text'
  552.      `-a' in `diff'.
  553.  
  554. `almost-all'
  555.      `-A' in `ls'.
  556.  
  557. `append'
  558.      `-a' in `etags', `tee', `time'; `-r' in `tar'.
  559.  
  560. `archive'
  561.      `-a' in `cp'.
  562.  
  563. `archive-name'
  564.      `-n' in `shar'.
  565.  
  566. `arglength'
  567.      `-l' in `m4'.
  568.  
  569. `ascii'
  570.      `-a' in `diff'.
  571.  
  572. `assign'
  573.      `-v' in `gawk'.
  574.  
  575. `assume-new'
  576.      `-W' in Make.
  577.  
  578. `assume-old'
  579.      `-o' in Make.
  580.  
  581. `auto-check'
  582.      `-a' in `recode'.
  583.  
  584. `auto-pager'
  585.      `-a' in `wdiff'.
  586.  
  587. `auto-reference'
  588.      `-A' in `ptx'.
  589.  
  590. `avoid-wraps'
  591.      `-n' in `wdiff'.
  592.  
  593. `backward-search'
  594.      `-B' in `ctags'.
  595.  
  596. `basename'
  597.      `-f' in `shar'.
  598.  
  599. `batch'
  600.      Used in GDB.
  601.  
  602. `baud'
  603.      Used in GDB.
  604.  
  605. `before'
  606.      `-b' in `tac'.
  607.  
  608. `binary'
  609.      `-b' in `cpio' and `diff'.
  610.  
  611. `bits-per-code'
  612.      `-b' in `shar'.
  613.  
  614. `block-size'
  615.      Used in `cpio' and `tar'.
  616.  
  617. `blocks'
  618.      `-b' in `head' and `tail'.
  619.  
  620. `break-file'
  621.      `-b' in `ptx'.
  622.  
  623. `brief'
  624.      Used in various programs to make output shorter.
  625.  
  626. `bytes'
  627.      `-c' in `head', `split', and `tail'.
  628.  
  629. `c++'
  630.      `-C' in `etags'.
  631.  
  632. `catenate'
  633.      `-A' in `tar'.
  634.  
  635. `cd'
  636.      Used in various programs to specify the directory to use.
  637.  
  638. `changes'
  639.      `-c' in `chgrp' and `chown'.
  640.  
  641. `classify'
  642.      `-F' in `ls'.
  643.  
  644. `colons'
  645.      `-c' in `recode'.
  646.  
  647. `command'
  648.      `-c' in `su'; `-x' in GDB.
  649.  
  650. `compare'
  651.      `-d' in `tar'.
  652.  
  653. `compat'
  654.      Used in `gawk'.
  655.  
  656. `compress'
  657.      `-Z' in `tar' and `shar'.
  658.  
  659. `concatenate'
  660.      `-A' in `tar'.
  661.  
  662. `confirmation'
  663.      `-w' in `tar'.
  664.  
  665. `context'
  666.      Used in `diff'.
  667.  
  668. `copyleft'
  669.      `-W copyleft' in `gawk'.
  670.  
  671. `copyright'
  672.      `-C' in `ptx', `recode', and `wdiff'; `-W copyright' in `gawk'.
  673.  
  674. `core'
  675.      Used in GDB.
  676.  
  677. `count'
  678.      `-q' in `who'.
  679.  
  680. `count-links'
  681.      `-l' in `du'.
  682.  
  683. `create'
  684.      Used in `tar' and `cpio'.
  685.  
  686. `cut-mark'
  687.      `-c' in `shar'.
  688.  
  689. `cxref'
  690.      `-x' in `ctags'.
  691.  
  692. `date'
  693.      `-d' in `touch'.
  694.  
  695. `debug'
  696.      `-d' in Make and `m4'; `-t' in Bison.
  697.  
  698. `define'
  699.      `-D' in `m4'.
  700.  
  701. `defines'
  702.      `-d' in Bison and `ctags'.
  703.  
  704. `delete'
  705.      `-D' in `tar'.
  706.  
  707. `dereference'
  708.      `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
  709.  
  710. `dereference-args'
  711.      `-D' in `du'.
  712.  
  713. `diacritics'
  714.      `-d' in `recode'.
  715.  
  716. `dictionary-order'
  717.      `-d' in `look'.
  718.  
  719. `diff'
  720.      `-d' in `tar'.
  721.  
  722. `digits'
  723.      `-n' in `csplit'.
  724.  
  725. `directory'
  726.      Specify the directory to use, in various programs.  In `ls', it
  727.      means to show directories themselves rather than their contents.
  728.      In `rm' and `ln', it means to not treat links to directories
  729.      specially.
  730.  
  731. `discard-all'
  732.      `-x' in `strip'.
  733.  
  734. `discard-locals'
  735.      `-X' in `strip'.
  736.  
  737. `dry-run'
  738.      `-n' in Make.
  739.  
  740. `ed'
  741.      `-e' in `diff'.
  742.  
  743. `elide-empty-files'
  744.      `-z' in `csplit'.
  745.  
  746. `end-delete'
  747.      `-x' in `wdiff'.
  748.  
  749. `end-insert'
  750.      `-z' in `wdiff'.
  751.  
  752. `entire-new-file'
  753.      `-N' in `diff'.
  754.  
  755. `environment-overrides'
  756.      `-e' in Make.
  757.  
  758. `eof'
  759.      `-e' in `xargs'.
  760.  
  761. `epoch'
  762.      Used in GDB.
  763.  
  764. `error-limit'
  765.      Used in `makeinfo'.
  766.  
  767. `error-output'
  768.      `-o' in `m4'.
  769.  
  770. `escape'
  771.      `-b' in `ls'.
  772.  
  773. `exclude-from'
  774.      `-X' in `tar'.
  775.  
  776. `exec'
  777.      Used in GDB.
  778.  
  779. `exit'
  780.      `-x' in `xargs'.
  781.  
  782. `exit-0'
  783.      `-e' in `unshar'.
  784.  
  785. `expand-tabs'
  786.      `-t' in `diff'.
  787.  
  788. `expression'
  789.      `-e' in `sed'.
  790.  
  791. `extern-only'
  792.      `-g' in `nm'.
  793.  
  794. `extract'
  795.      `-i' in `cpio'; `-x' in `tar'.
  796.  
  797. `faces'
  798.      `-f' in `finger'.
  799.  
  800. `fast'
  801.      `-f' in `su'.
  802.  
  803. `fatal-warnings'
  804.      `-E' in `m4'.
  805.  
  806. `file'
  807.      `-f' in `info', `gawk', Make, `mt', and `tar'; `-n' in `sed'; `-r'
  808.      in `touch'.
  809.  
  810. `field-separator'
  811.      `-F' in `gawk'.
  812.  
  813. `file-prefix'
  814.      `-b' in Bison.
  815.  
  816. `file-type'
  817.      `-F' in `ls'.
  818.  
  819. `files-from'
  820.      `-T' in `tar'.
  821.  
  822. `fill-column'
  823.      Used in `makeinfo'.
  824.  
  825. `flag-truncation'
  826.      `-F' in `ptx'.
  827.  
  828. `fixed-output-files'
  829.      `-y' in Bison.
  830.  
  831. `follow'
  832.      `-f' in `tail'.
  833.  
  834. `footnote-style'
  835.      Used in `makeinfo'.
  836.  
  837. `force'
  838.      `-f' in `cp', `ln', `mv', and `rm'.
  839.  
  840. `force-prefix'
  841.      `-F' in `shar'.
  842.  
  843. `format'
  844.      Used in `ls', `time', and `ptx'.
  845.  
  846. `freeze-state'
  847.      `-F' in `m4'.
  848.  
  849. `fullname'
  850.      Used in GDB.
  851.  
  852. `gap-size'
  853.      `-g' in `ptx'.
  854.  
  855. `get'
  856.      `-x' in `tar'.
  857.  
  858. `graphic'
  859.      `-i' in `ul'.
  860.  
  861. `graphics'
  862.      `-g' in `recode'.
  863.  
  864. `group'
  865.      `-g' in `install'.
  866.  
  867. `gzip'
  868.      `-z' in `tar' and `shar'.
  869.  
  870. `hashsize'
  871.      `-H' in `m4'.
  872.  
  873. `header'
  874.      `-h' in `objdump' and `recode'
  875.  
  876. `heading'
  877.      `-H' in `who'.
  878.  
  879. `help'
  880.      Used to ask for brief usage information.
  881.  
  882. `here-delimiter'
  883.      `-d' in `shar'.
  884.  
  885. `hide-control-chars'
  886.      `-q' in `ls'.
  887.  
  888. `idle'
  889.      `-u' in `who'.
  890.  
  891. `ifdef'
  892.      `-D' in `diff'.
  893.  
  894. `ignore'
  895.      `-I' in `ls'; `-x' in `recode'.
  896.  
  897. `ignore-all-space'
  898.      `-w' in `diff'.
  899.  
  900. `ignore-backups'
  901.      `-B' in `ls'.
  902.  
  903. `ignore-blank-lines'
  904.      `-B' in `diff'.
  905.  
  906. `ignore-case'
  907.      `-f' in `look' and `ptx'; `-i' in `diff' and `wdiff'.
  908.  
  909. `ignore-errors'
  910.      `-i' in Make.
  911.  
  912. `ignore-file'
  913.      `-i' in `ptx'.
  914.  
  915. `ignore-indentation'
  916.      `-I' in `etags'.
  917.  
  918. `ignore-init-file'
  919.      `-f' in Oleo.
  920.  
  921. `ignore-interrupts'
  922.      `-i' in `tee'.
  923.  
  924. `ignore-matching-lines'
  925.      `-I' in `diff'.
  926.  
  927. `ignore-space-change'
  928.      `-b' in `diff'.
  929.  
  930. `ignore-zeros'
  931.      `-i' in `tar'.
  932.  
  933. `include'
  934.      `-i' in `etags'; `-I' in `m4'.
  935.  
  936. `include-dir'
  937.      `-I' in Make.
  938.  
  939. `incremental'
  940.      `-G' in `tar'.
  941.  
  942. `info'
  943.      `-i', `-l', and `-m' in Finger.
  944.  
  945. `initial'
  946.      `-i' in `expand'.
  947.  
  948. `initial-tab'
  949.      `-T' in `diff'.
  950.  
  951. `inode'
  952.      `-i' in `ls'.
  953.  
  954. `interactive'
  955.      `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
  956.      `-w' in `tar'.
  957.  
  958. `intermix-type'
  959.      `-p' in `shar'.
  960.  
  961. `jobs'
  962.      `-j' in Make.
  963.  
  964. `just-print'
  965.      `-n' in Make.
  966.  
  967. `keep-going'
  968.      `-k' in Make.
  969.  
  970. `keep-files'
  971.      `-k' in `csplit'.
  972.  
  973. `kilobytes'
  974.      `-k' in `du' and `ls'.
  975.  
  976. `language'
  977.      `-l' in `etags'.
  978.  
  979. `less-mode'
  980.      `-l' in `wdiff'.
  981.  
  982. `level-for-gzip'
  983.      `-g' in `shar'.
  984.  
  985. `line-bytes'
  986.      `-C' in `split'.
  987.  
  988. `lines'
  989.      Used in `split', `head', and `tail'.
  990.  
  991. `link'
  992.      `-l' in `cpio'.
  993.  
  994. `lint'
  995. `lint-old'
  996.      Used in `gawk'.
  997.  
  998. `list'
  999.      `-t' in `cpio'; `-l' in `recode'.
  1000.  
  1001. `list'
  1002.      `-t' in `tar'.
  1003.  
  1004. `literal'
  1005.      `-N' in `ls'.
  1006.  
  1007. `load-average'
  1008.      `-l' in Make.
  1009.  
  1010. `login'
  1011.      Used in `su'.
  1012.  
  1013. `machine'
  1014.      No listing of which programs already use this; someone should
  1015.      check to see if any actually do and tell `gnu@prep.ai.mit.edu'.
  1016.  
  1017. `macro-name'
  1018.      `-M' in `ptx'.
  1019.  
  1020. `mail'
  1021.      `-m' in `hello' and `uname'.
  1022.  
  1023. `make-directories'
  1024.      `-d' in `cpio'.
  1025.  
  1026. `makefile'
  1027.      `-f' in Make.
  1028.  
  1029. `mapped'
  1030.      Used in GDB.
  1031.  
  1032. `max-args'
  1033.      `-n' in `xargs'.
  1034.  
  1035. `max-chars'
  1036.      `-n' in `xargs'.
  1037.  
  1038. `max-lines'
  1039.      `-l' in `xargs'.
  1040.  
  1041. `max-load'
  1042.      `-l' in Make.
  1043.  
  1044. `max-procs'
  1045.      `-P' in `xargs'.
  1046.  
  1047. `mesg'
  1048.      `-T' in `who'.
  1049.  
  1050. `message'
  1051.      `-T' in `who'.
  1052.  
  1053. `minimal'
  1054.      `-d' in `diff'.
  1055.  
  1056. `mixed-uuencode'
  1057.      `-M' in `shar'.
  1058.  
  1059. `mode'
  1060.      `-m' in `install', `mkdir', and `mkfifo'.
  1061.  
  1062. `modification-time'
  1063.      `-m' in `tar'.
  1064.  
  1065. `multi-volume'
  1066.      `-M' in `tar'.
  1067.  
  1068. `name-prefix'
  1069.      `-a' in Bison.
  1070.  
  1071. `nesting-limit'
  1072.      `-L' in `m4'.
  1073.  
  1074. `net-headers'
  1075.      `-a' in `shar'.
  1076.  
  1077. `new-file'
  1078.      `-W' in Make.
  1079.  
  1080. `no-builtin-rules'
  1081.      `-r' in Make.
  1082.  
  1083. `no-character-count'
  1084.      `-w' in `shar'.
  1085.  
  1086. `no-check-existing'
  1087.      `-x' in `shar'.
  1088.  
  1089. `no-common'
  1090.      `-3' in `wdiff'.
  1091.  
  1092. `no-create'
  1093.      `-c' in `touch'.
  1094.  
  1095. `no-defines'
  1096.      `-D' in `etags'.
  1097.  
  1098. `no-deleted'
  1099.      `-1' in `wdiff'.
  1100.  
  1101. `no-dereference'
  1102.      `-d' in `cp'.
  1103.  
  1104. `no-inserted'
  1105.      `-2' in `wdiff'.
  1106.  
  1107. `no-keep-going'
  1108.      `-S' in Make.
  1109.  
  1110. `no-lines'
  1111.      `-l' in Bison.
  1112.  
  1113. `no-piping'
  1114.      `-P' in `shar'.
  1115.  
  1116. `no-prof'
  1117.      `-e' in `gprof'.
  1118.  
  1119. `no-regex'
  1120.      `-R' in `etags'.
  1121.  
  1122. `no-sort'
  1123.      `-p' in `nm'.
  1124.  
  1125. `no-split'
  1126.      Used in `makeinfo'.
  1127.  
  1128. `no-static'
  1129.      `-a' in `gprof'.
  1130.  
  1131. `no-time'
  1132.      `-E' in `gprof'.
  1133.  
  1134. `no-timestamp'
  1135.      `-m' in `shar'.
  1136.  
  1137. `no-validate'
  1138.      Used in `makeinfo'.
  1139.  
  1140. `no-warn'
  1141.      Used in various programs to inhibit warnings.
  1142.  
  1143. `node'
  1144.      `-n' in `info'.
  1145.  
  1146. `nodename'
  1147.      `-n' in `uname'.
  1148.  
  1149. `nonmatching'
  1150.      `-f' in `cpio'.
  1151.  
  1152. `nstuff'
  1153.      `-n' in `objdump'.
  1154.  
  1155. `null'
  1156.      `-0' in `xargs'.
  1157.  
  1158. `number'
  1159.      `-n' in `cat'.
  1160.  
  1161. `number-nonblank'
  1162.      `-b' in `cat'.
  1163.  
  1164. `numeric-sort'
  1165.      `-n' in `nm'.
  1166.  
  1167. `numeric-uid-gid'
  1168.      `-n' in `cpio' and `ls'.
  1169.  
  1170. `nx'
  1171.      Used in GDB.
  1172.  
  1173. `old-archive'
  1174.      `-o' in `tar'.
  1175.  
  1176. `old-file'
  1177.      `-o' in Make.
  1178.  
  1179. `one-file-system'
  1180.      `-l' in `tar', `cp', and `du'.
  1181.  
  1182. `only-file'
  1183.      `-o' in `ptx'.
  1184.  
  1185. `only-prof'
  1186.      `-f' in `gprof'.
  1187.  
  1188. `only-time'
  1189.      `-F' in `gprof'.
  1190.  
  1191. `output'
  1192.      In various programs, specify the output file name.
  1193.  
  1194. `output-prefix'
  1195.      `-o' in `shar'.
  1196.  
  1197. `override'
  1198.      `-o' in `rm'.
  1199.  
  1200. `overwrite'
  1201.      `-c' in `unshar'.
  1202.  
  1203. `owner'
  1204.      `-o' in `install'.
  1205.  
  1206. `paginate'
  1207.      `-l' in `diff'.
  1208.  
  1209. `paragraph-indent'
  1210.      Used in `makeinfo'.
  1211.  
  1212. `parents'
  1213.      `-p' in `mkdir' and `rmdir'.
  1214.  
  1215. `pass-all'
  1216.      `-p' in `ul'.
  1217.  
  1218. `pass-through'
  1219.      `-p' in `cpio'.
  1220.  
  1221. `port'
  1222.      `-P' in `finger'.
  1223.  
  1224. `portability'
  1225.      `-c' in `cpio' and `tar'.
  1226.  
  1227. `posix'
  1228.      Used in `gawk'.
  1229.  
  1230. `prefix-builtins'
  1231.      `-P' in `m4'.
  1232.  
  1233. `prefix'
  1234.      `-f' in `csplit'.
  1235.  
  1236. `preserve'
  1237.      Used in `tar' and `cp'.
  1238.  
  1239. `preserve-environment'
  1240.      `-p' in `su'.
  1241.  
  1242. `preserve-modification-time'
  1243.      `-m' in `cpio'.
  1244.  
  1245. `preserve-order'
  1246.      `-s' in `tar'.
  1247.  
  1248. `preserve-permissions'
  1249.      `-p' in `tar'.
  1250.  
  1251. `print'
  1252.      `-l' in `diff'.
  1253.  
  1254. `print-chars'
  1255.      `-L' in `cmp'.
  1256.  
  1257. `print-data-base'
  1258.      `-p' in Make.
  1259.  
  1260. `print-directory'
  1261.      `-w' in Make.
  1262.  
  1263. `print-file-name'
  1264.      `-o' in `nm'.
  1265.  
  1266. `print-symdefs'
  1267.      `-s' in `nm'.
  1268.  
  1269. `printer'
  1270.      `-p' in `wdiff'.
  1271.  
  1272. `prompt'
  1273.      `-p' in `ed'.
  1274.  
  1275. `query-user'
  1276.      `-X' in `shar'.
  1277.  
  1278. `question'
  1279.      `-q' in Make.
  1280.  
  1281. `quiet'
  1282.      Used in many programs to inhibit the usual output.  *Note:* every
  1283.      program accepting `--quiet' should accept `--silent' as a synonym.
  1284.  
  1285. `quiet-unshar'
  1286.      `-Q' in `shar'
  1287.  
  1288. `quote-name'
  1289.      `-Q' in `ls'.
  1290.  
  1291. `rcs'
  1292.      `-n' in `diff'.
  1293.  
  1294. `re-interval'
  1295.      Used in `gawk'.
  1296.  
  1297. `read-full-blocks'
  1298.      `-B' in `tar'.
  1299.  
  1300. `readnow'
  1301.      Used in GDB.
  1302.  
  1303. `recon'
  1304.      `-n' in Make.
  1305.  
  1306. `record-number'
  1307.      `-R' in `tar'.
  1308.  
  1309. `recursive'
  1310.      Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
  1311.  
  1312. `reference-limit'
  1313.      Used in `makeinfo'.
  1314.  
  1315. `references'
  1316.      `-r' in `ptx'.
  1317.  
  1318. `regex'
  1319.      `-r' in `tac' and `etags'.
  1320.  
  1321. `release'
  1322.      `-r' in `uname'.
  1323.  
  1324. `reload-state'
  1325.      `-R' in `m4'.
  1326.  
  1327. `relocation'
  1328.      `-r' in `objdump'.
  1329.  
  1330. `rename'
  1331.      `-r' in `cpio'.
  1332.  
  1333. `replace'
  1334.      `-i' in `xargs'.
  1335.  
  1336. `report-identical-files'
  1337.      `-s' in `diff'.
  1338.  
  1339. `reset-access-time'
  1340.      `-a' in `cpio'.
  1341.  
  1342. `reverse'
  1343.      `-r' in `ls' and `nm'.
  1344.  
  1345. `reversed-ed'
  1346.      `-f' in `diff'.
  1347.  
  1348. `right-side-defs'
  1349.      `-R' in `ptx'.
  1350.  
  1351. `same-order'
  1352.      `-s' in `tar'.
  1353.  
  1354. `same-permissions'
  1355.      `-p' in `tar'.
  1356.  
  1357. `save'
  1358.      `-g' in `stty'.
  1359.  
  1360. `se'
  1361.      Used in GDB.
  1362.  
  1363. `sentence-regexp'
  1364.      `-S' in `ptx'.
  1365.  
  1366. `separate-dirs'
  1367.      `-S' in `du'.
  1368.  
  1369. `separator'
  1370.      `-s' in `tac'.
  1371.  
  1372. `sequence'
  1373.      Used by `recode' to chose files or pipes for sequencing passes.
  1374.  
  1375. `shell'
  1376.      `-s' in `su'.
  1377.  
  1378. `show-all'
  1379.      `-A' in `cat'.
  1380.  
  1381. `show-c-function'
  1382.      `-p' in `diff'.
  1383.  
  1384. `show-ends'
  1385.      `-E' in `cat'.
  1386.  
  1387. `show-function-line'
  1388.      `-F' in `diff'.
  1389.  
  1390. `show-tabs'
  1391.      `-T' in `cat'.
  1392.  
  1393. `silent'
  1394.      Used in many programs to inhibit the usual output.  *Note:* every
  1395.      program accepting `--silent' should accept `--quiet' as a synonym.
  1396.  
  1397. `size'
  1398.      `-s' in `ls'.
  1399.  
  1400. `sort'
  1401.      Used in `ls'.
  1402.  
  1403. `source'
  1404.      `-W source' in `gawk'.
  1405.  
  1406. `sparse'
  1407.      `-S' in `tar'.
  1408.  
  1409. `speed-large-files'
  1410.      `-H' in `diff'.
  1411.  
  1412. `split-at'
  1413.      `-E' in `unshar'.
  1414.  
  1415. `split-size-limit'
  1416.      `-L' in `shar'.
  1417.  
  1418. `squeeze-blank'
  1419.      `-s' in `cat'.
  1420.  
  1421. `start-delete'
  1422.      `-w' in `wdiff'.
  1423.  
  1424. `start-insert'
  1425.      `-y' in `wdiff'.
  1426.  
  1427. `starting-file'
  1428.      Used in `tar' and `diff' to specify which file within a directory
  1429.      to start processing with.
  1430.  
  1431. `statistics'
  1432.      `-s' in `wdiff'.
  1433.  
  1434. `stdin-file-list'
  1435.      `-S' in `shar'.
  1436.  
  1437. `stop'
  1438.      `-S' in Make.
  1439.  
  1440. `strict'
  1441.      `-s' in `recode'.
  1442.  
  1443. `strip'
  1444.      `-s' in `install'.
  1445.  
  1446. `strip-all'
  1447.      `-s' in `strip'.
  1448.  
  1449. `strip-debug'
  1450.      `-S' in `strip'.
  1451.  
  1452. `submitter'
  1453.      `-s' in `shar'.
  1454.  
  1455. `suffix'
  1456.      `-S' in `cp', `ln', `mv'.
  1457.  
  1458. `suffix-format'
  1459.      `-b' in `csplit'.
  1460.  
  1461. `sum'
  1462.      `-s' in `gprof'.
  1463.  
  1464. `summarize'
  1465.      `-s' in `du'.
  1466.  
  1467. `symbolic'
  1468.      `-s' in `ln'.
  1469.  
  1470. `symbols'
  1471.      Used in GDB and `objdump'.
  1472.  
  1473. `synclines'
  1474.      `-s' in `m4'.
  1475.  
  1476. `sysname'
  1477.      `-s' in `uname'.
  1478.  
  1479. `tabs'
  1480.      `-t' in `expand' and `unexpand'.
  1481.  
  1482. `tabsize'
  1483.      `-T' in `ls'.
  1484.  
  1485. `terminal'
  1486.      `-T' in `tput' and `ul'.  `-t' in `wdiff'.
  1487.  
  1488. `text'
  1489.      `-a' in `diff'.
  1490.  
  1491. `text-files'
  1492.      `-T' in `shar'.
  1493.  
  1494. `time'
  1495.      Used in `ls' and `touch'.
  1496.  
  1497. `to-stdout'
  1498.      `-O' in `tar'.
  1499.  
  1500. `total'
  1501.      `-c' in `du'.
  1502.  
  1503. `touch'
  1504.      `-t' in Make, `ranlib', and `recode'.
  1505.  
  1506. `trace'
  1507.      `-t' in `m4'.
  1508.  
  1509. `traditional'
  1510.      `-t' in `hello'; `-W traditional' in `gawk'; `-G' in `ed', `m4',
  1511.      and `ptx'.
  1512.  
  1513. `tty'
  1514.      Used in GDB.
  1515.  
  1516. `typedefs'
  1517.      `-t' in `ctags'.
  1518.  
  1519. `typedefs-and-c++'
  1520.      `-T' in `ctags'.
  1521.  
  1522. `typeset-mode'
  1523.      `-t' in `ptx'.
  1524.  
  1525. `uncompress'
  1526.      `-z' in `tar'.
  1527.  
  1528. `unconditional'
  1529.      `-u' in `cpio'.
  1530.  
  1531. `undefine'
  1532.      `-U' in `m4'.
  1533.  
  1534. `undefined-only'
  1535.      `-u' in `nm'.
  1536.  
  1537. `update'
  1538.      `-u' in `cp', `ctags', `mv', `tar'.
  1539.  
  1540. `usage'
  1541.      Used in `gawk'; same as `--help'.
  1542.  
  1543. `uuencode'
  1544.      `-B' in `shar'.
  1545.  
  1546. `vanilla-operation'
  1547.      `-V' in `shar'.
  1548.  
  1549. `verbose'
  1550.      Print more information about progress.  Many programs support this.
  1551.  
  1552. `verify'
  1553.      `-W' in `tar'.
  1554.  
  1555. `version'
  1556.      Print the version number.
  1557.  
  1558. `version-control'
  1559.      `-V' in `cp', `ln', `mv'.
  1560.  
  1561. `vgrind'
  1562.      `-v' in `ctags'.
  1563.  
  1564. `volume'
  1565.      `-V' in `tar'.
  1566.  
  1567. `what-if'
  1568.      `-W' in Make.
  1569.  
  1570. `whole-size-limit'
  1571.      `-l' in `shar'.
  1572.  
  1573. `width'
  1574.      `-w' in `ls' and `ptx'.
  1575.  
  1576. `word-regexp'
  1577.      `-W' in `ptx'.
  1578.  
  1579. `writable'
  1580.      `-T' in `who'.
  1581.  
  1582. `zeros'
  1583.      `-z' in `gprof'.
  1584.  
  1585. 
  1586. File: standards.info,  Node: Memory Usage,  Prev: User Interfaces,  Up: Program Behavior
  1587.  
  1588. Memory Usage
  1589. ============
  1590.  
  1591.    If it typically uses just a few meg of memory, don't bother making
  1592. any effort to reduce memory usage.  For example, if it is impractical
  1593. for other reasons to operate on files more than a few meg long, it is
  1594. reasonable to read entire input files into core to operate on them.
  1595.  
  1596.    However, for programs such as `cat' or `tail', that can usefully
  1597. operate on very large files, it is important to avoid using a technique
  1598. that would artificially limit the size of files it can handle.  If a
  1599. program works by lines and could be applied to arbitrary user-supplied
  1600. input files, it should keep only a line in memory, because this is not
  1601. very hard and users will want to be able to operate on input files that
  1602. are bigger than will fit in core all at once.
  1603.  
  1604.    If your program creates complicated data structures, just make them
  1605. in core and give a fatal error if `malloc' returns zero.
  1606.  
  1607. 
  1608. File: standards.info,  Node: Writing C,  Next: Documentation,  Prev: Program Behavior,  Up: Top
  1609.  
  1610. Making The Best Use of C
  1611. ************************
  1612.  
  1613.    This node provides advice on how best to use the C language when
  1614. writing GNU software.
  1615.  
  1616. * Menu:
  1617.  
  1618. * Formatting::            Formatting Your Source Code
  1619. * Comments::            Commenting Your Work
  1620. * Syntactic Conventions::    Clean Use of C Constructs
  1621. * Names::            Naming Variables and Functions
  1622. * System Portability::        Portability between different operating systems
  1623. * CPU Portability::             Supporting the range of CPU types
  1624. * System Functions::            Portability and "standard" library functions
  1625. * Internationalization::        Techniques for internationalization
  1626.  
  1627. 
  1628. File: standards.info,  Node: Formatting,  Next: Comments,  Up: Writing C
  1629.  
  1630. Formatting Your Source Code
  1631. ===========================
  1632.  
  1633.    It is important to put the open-brace that starts the body of a C
  1634. function in column zero, and avoid putting any other open-brace or
  1635. open-parenthesis or open-bracket in column zero.  Several tools look
  1636. for open-braces in column zero to find the beginnings of C functions.
  1637. These tools will not work on code not formatted that way.
  1638.  
  1639.    It is also important for function definitions to start the name of
  1640. the function in column zero.  This helps people to search for function
  1641. definitions, and may also help certain tools recognize them.  Thus, the
  1642. proper format is this:
  1643.  
  1644.      static char *
  1645.      concat (s1, s2)        /* Name starts in column zero here */
  1646.           char *s1, *s2;
  1647.      {                     /* Open brace in column zero here */
  1648.        ...
  1649.      }
  1650.  
  1651. or, if you want to use ANSI C, format the definition like this:
  1652.  
  1653.      static char *
  1654.      concat (char *s1, char *s2)
  1655.      {
  1656.        ...
  1657.      }
  1658.  
  1659.    In ANSI C, if the arguments don't fit nicely on one line, split it
  1660. like this:
  1661.  
  1662.      int
  1663.      lots_of_args (int an_integer, long a_long, short a_short,
  1664.                    double a_double, float a_float)
  1665.      ...
  1666.  
  1667.    For the body of the function, we prefer code formatted like this:
  1668.  
  1669.      if (x < foo (y, z))
  1670.        haha = bar[4] + 5;
  1671.      else
  1672.        {
  1673.          while (z)
  1674.            {
  1675.              haha += foo (z, z);
  1676.              z--;
  1677.            }
  1678.          return ++x + bar ();
  1679.        }
  1680.  
  1681.    We find it easier to read a program when it has spaces before the
  1682. open-parentheses and after the commas.  Especially after the commas.
  1683.  
  1684.    When you split an expression into multiple lines, split it before an
  1685. operator, not after one.  Here is the right way:
  1686.  
  1687.      if (foo_this_is_long && bar > win (x, y, z)
  1688.          && remaining_condition)
  1689.  
  1690.    Try to avoid having two operators of different precedence at the same
  1691. level of indentation.  For example, don't write this:
  1692.  
  1693.      mode = (inmode[j] == VOIDmode
  1694.              || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
  1695.              ? outmode[j] : inmode[j]);
  1696.  
  1697.    Instead, use extra parentheses so that the indentation shows the
  1698. nesting:
  1699.  
  1700.      mode = ((inmode[j] == VOIDmode
  1701.               || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
  1702.              ? outmode[j] : inmode[j]);
  1703.  
  1704.    Insert extra parentheses so that Emacs will indent the code properly.
  1705. For example, the following indentation looks nice if you do it by hand,
  1706. but Emacs would mess it up:
  1707.  
  1708.      v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
  1709.          + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
  1710.  
  1711.    But adding a set of parentheses solves the problem:
  1712.  
  1713.      v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
  1714.           + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
  1715.  
  1716.    Format do-while statements like this:
  1717.  
  1718.      do
  1719.        {
  1720.          a = foo (a);
  1721.        }
  1722.      while (a > 0);
  1723.  
  1724.    Please use formfeed characters (control-L) to divide the program into
  1725. pages at logical places (but not within a function).  It does not matter
  1726. just how long the pages are, since they do not have to fit on a printed
  1727. page.  The formfeeds should appear alone on lines by themselves.
  1728.  
  1729. 
  1730. File: standards.info,  Node: Comments,  Next: Syntactic Conventions,  Prev: Formatting,  Up: Writing C
  1731.  
  1732. Commenting Your Work
  1733. ====================
  1734.  
  1735.    Every program should start with a comment saying briefly what it is
  1736. for.  Example: `fmt - filter for simple filling of text'.
  1737.  
  1738.    Please put a comment on each function saying what the function does,
  1739. what sorts of arguments it gets, and what the possible values of
  1740. arguments mean and are used for.  It is not necessary to duplicate in
  1741. words the meaning of the C argument declarations, if a C type is being
  1742. used in its customary fashion.  If there is anything nonstandard about
  1743. its use (such as an argument of type `char *' which is really the
  1744. address of the second character of a string, not the first), or any
  1745. possible values that would not work the way one would expect (such as,
  1746. that strings containing newlines are not guaranteed to work), be sure
  1747. to say so.
  1748.  
  1749.    Also explain the significance of the return value, if there is one.
  1750.  
  1751.    Please put two spaces after the end of a sentence in your comments,
  1752. so that the Emacs sentence commands will work.  Also, please write
  1753. complete sentences and capitalize the first word.  If a lower-case
  1754. identifier comes at the beginning of a sentence, don't capitalize it!
  1755. Changing the spelling makes it a different identifier.  If you don't
  1756. like starting a sentence with a lower case letter, write the sentence
  1757. differently (e.g., "The identifier lower-case is ...").
  1758.  
  1759.    The comment on a function is much clearer if you use the argument
  1760. names to speak about the argument values.  The variable name itself
  1761. should be lower case, but write it in upper case when you are speaking
  1762. about the value rather than the variable itself.  Thus, "the inode
  1763. number NODE_NUM" rather than "an inode".
  1764.  
  1765.    There is usually no purpose in restating the name of the function in
  1766. the comment before it, because the reader can see that for himself.
  1767. There might be an exception when the comment is so long that the
  1768. function itself would be off the bottom of the screen.
  1769.  
  1770.    There should be a comment on each static variable as well, like this:
  1771.  
  1772.      /* Nonzero means truncate lines in the display;
  1773.         zero means continue them.  */
  1774.      int truncate_lines;
  1775.  
  1776.    Every `#endif' should have a comment, except in the case of short
  1777. conditionals (just a few lines) that are not nested.  The comment should
  1778. state the condition of the conditional that is ending, *including its
  1779. sense*.  `#else' should have a comment describing the condition *and
  1780. sense* of the code that follows.  For example:
  1781.  
  1782.      #ifdef foo
  1783.        ...
  1784.      #else /* not foo */
  1785.        ...
  1786.      #endif /* not foo */
  1787.  
  1788. but, by contrast, write the comments this way for a `#ifndef':
  1789.  
  1790.      #ifndef foo
  1791.        ...
  1792.      #else /* foo */
  1793.        ...
  1794.      #endif /* foo */
  1795.  
  1796. 
  1797. File: standards.info,  Node: Syntactic Conventions,  Next: Names,  Prev: Comments,  Up: Writing C
  1798.  
  1799. Clean Use of C Constructs
  1800. =========================
  1801.  
  1802.    Please explicitly declare all arguments to functions.  Don't omit
  1803. them just because they are `int's.
  1804.  
  1805.    Declarations of external functions and functions to appear later in
  1806. the source file should all go in one place near the beginning of the
  1807. file (somewhere before the first function definition in the file), or
  1808. else should go in a header file.  Don't put `extern' declarations inside
  1809. functions.
  1810.  
  1811.    It used to be common practice to use the same local variables (with
  1812. names like `tem') over and over for different values within one
  1813. function.  Instead of doing this, it is better declare a separate local
  1814. variable for each distinct purpose, and give it a name which is
  1815. meaningful.  This not only makes programs easier to understand, it also
  1816. facilitates optimization by good compilers.  You can also move the
  1817. declaration of each local variable into the smallest scope that includes
  1818. all its uses.  This makes the program even cleaner.
  1819.  
  1820.    Don't use local variables or parameters that shadow global
  1821. identifiers.
  1822.  
  1823.    Don't declare multiple variables in one declaration that spans lines.
  1824. Start a new declaration on each line, instead.  For example, instead of
  1825. this:
  1826.  
  1827.      int    foo,
  1828.             bar;
  1829.  
  1830. write either this:
  1831.  
  1832.      int foo, bar;
  1833.  
  1834. or this:
  1835.  
  1836.      int foo;
  1837.      int bar;
  1838.  
  1839. (If they are global variables, each should have a comment preceding it
  1840. anyway.)
  1841.  
  1842.    When you have an `if'-`else' statement nested in another `if'
  1843. statement, always put braces around the `if'-`else'.  Thus, never write
  1844. like this:
  1845.  
  1846.      if (foo)
  1847.        if (bar)
  1848.          win ();
  1849.        else
  1850.          lose ();
  1851.  
  1852. always like this:
  1853.  
  1854.      if (foo)
  1855.        {
  1856.          if (bar)
  1857.            win ();
  1858.          else
  1859.            lose ();
  1860.        }
  1861.  
  1862.    If you have an `if' statement nested inside of an `else' statement,
  1863. either write `else if' on one line, like this,
  1864.  
  1865.      if (foo)
  1866.        ...
  1867.      else if (bar)
  1868.        ...
  1869.  
  1870. with its `then'-part indented like the preceding `then'-part, or write
  1871. the nested `if' within braces like this:
  1872.  
  1873.      if (foo)
  1874.        ...
  1875.      else
  1876.        {
  1877.          if (bar)
  1878.            ...
  1879.        }
  1880.  
  1881.    Don't declare both a structure tag and variables or typedefs in the
  1882. same declaration.  Instead, declare the structure tag separately and
  1883. then use it to declare the variables or typedefs.
  1884.  
  1885.    Try to avoid assignments inside `if'-conditions.  For example, don't
  1886. write this:
  1887.  
  1888.      if ((foo = (char *) malloc (sizeof *foo)) == 0)
  1889.        fatal ("virtual memory exhausted");
  1890.  
  1891. instead, write this:
  1892.  
  1893.      foo = (char *) malloc (sizeof *foo);
  1894.      if (foo == 0)
  1895.        fatal ("virtual memory exhausted");
  1896.  
  1897.    Don't make the program ugly to placate `lint'.  Please don't insert
  1898. any casts to `void'.  Zero without a cast is perfectly fine as a null
  1899. pointer constant, except when calling a varargs function.
  1900.  
  1901. 
  1902. File: standards.info,  Node: Names,  Next: System Portability,  Prev: Syntactic Conventions,  Up: Writing C
  1903.  
  1904. Naming Variables and Functions
  1905. ==============================
  1906.  
  1907.    Please use underscores to separate words in a name, so that the Emacs
  1908. word commands can be useful within them.  Stick to lower case; reserve
  1909. upper case for macros and `enum' constants, and for name-prefixes that
  1910. follow a uniform convention.
  1911.  
  1912.    For example, you should use names like `ignore_space_change_flag';
  1913. don't use names like `iCantReadThis'.
  1914.  
  1915.    Variables that indicate whether command-line options have been
  1916. specified should be named after the meaning of the option, not after
  1917. the option-letter.  A comment should state both the exact meaning of
  1918. the option and its letter.  For example,
  1919.  
  1920.      /* Ignore changes in horizontal whitespace (-b).  */
  1921.      int ignore_space_change_flag;
  1922.  
  1923.    When you want to define names with constant integer values, use
  1924. `enum' rather than `#define'.  GDB knows about enumeration constants.
  1925.  
  1926.    Use file names of 14 characters or less, to avoid creating gratuitous
  1927. problems on older System V systems.  You can use the program `doschk'
  1928. to test for this.  `doschk' also tests for potential name conflicts if
  1929. the files were loaded onto an MS-DOS file system--something you may or
  1930. may not care about.
  1931.  
  1932. 
  1933. File: standards.info,  Node: System Portability,  Next: CPU Portability,  Prev: Names,  Up: Writing C
  1934.  
  1935. Portability between System Types
  1936. ================================
  1937.  
  1938.    In the Unix world, "portability" refers to porting to different Unix
  1939. versions.  For a GNU program, this kind of portability is desirable, but
  1940. not paramount.
  1941.  
  1942.    The primary purpose of GNU software is to run on top of the GNU
  1943. kernel, compiled with the GNU C compiler, on various types of CPU.  The
  1944. amount and kinds of variation among GNU systems on different CPUs will
  1945. be comparable to the variation among Linux-based GNU systems or among
  1946. BSD systems today.  So the kinds of portability that are absolutely
  1947. necessary are quite limited.
  1948.  
  1949.    But many users do run GNU software on non-GNU Unix or Unix-like
  1950. systems.  So supporting a variety of Unix-like systems is desirable,
  1951. although not paramount.
  1952.  
  1953.    The easiest way to achieve portability to most Unix-like systems is
  1954. to use Autoconf.  It's unlikely that your program needs to know more
  1955. information about the host platform than Autoconf can provide, simply
  1956. because most of the programs that need such knowledge have already been
  1957. written.
  1958.  
  1959.    Avoid using the format of semi-internal data bases (e.g.,
  1960. directories) when there is a higher-level alternative (`readdir').
  1961.  
  1962.    As for systems that are not like Unix, such as MSDOS, Windows, the
  1963. Macintosh, VMS, and MVS, supporting them is usually so much work that it
  1964. is better if you don't.
  1965.  
  1966.    The planned GNU kernel is not finished yet, but you can tell which
  1967. facilities it will provide by looking at the GNU C Library Manual.  The
  1968. GNU kernel is based on Mach, so the features of Mach will also be
  1969. available.  However, if you use Mach features, you'll probably have
  1970. trouble debugging your program today.
  1971.  
  1972.